home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Window.h
-
- Contains: Definition of TWindow, a base class which provides a
- framework for building way-cool windows which even John
- Sullivan would be happy with. Floating windows and “smart
- zooming” algorithms are based on code samples provided by
- Dean Yu.
-
- Written by: Dave Falkenburg, Dean Yu
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- <4> 11/12/94 DRF Added AdjustMenusBeforeMenuSelection.
- <3> 11/8/94 DRF Add some better menu handling methods.
- <2> 9/4/94 DRF Added DrawJustTheGrowIcon.
- */
-
- #ifndef _WINDOW_
- #define _WINDOW_
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
- #ifndef __DRAG__
- #include <Drag.h>
- #endif
-
- typedef short WindowTemplateID;
-
-
- class TWindow
- {
- public:
- enum WindowType
- {
- kNormalWindow = 0,
- kFloatingWindow,
- kModalWindow
- };
-
- TWindow();
- virtual ~TWindow();
-
- // Event routing methods
-
- virtual Boolean EventFilter(EventRecord * theEvent);
-
- // Methods you shouldn’t need to override, but might need to
-
- virtual void CreateWindow(WindowType typeOfWindowToCreate = kNormalWindow);
- virtual void Select(void);
- virtual void Drag(Point startPoint);
- virtual void Nudge(short horizontalDistance, short verticalDistance);
- virtual void Grow(Point startPoint);
- virtual void Zoom(short zoomState);
-
- virtual void ShowHide(Boolean showFlag);
-
- // Methods which MUST be overridden:
-
- virtual WindowPtr MakeNewWindow(WindowPtr behindWindow) = 0;
-
-
- // Methods which probably should be overridden
-
- virtual void AdjustCursor(EventRecord * anEvent);
- virtual void Idle(EventRecord * anEvent);
- virtual void Activate(Boolean activating);
- virtual void Draw(void);
- virtual void Click(EventRecord * anEvent);
- virtual void KeyDown(EventRecord * anEvent);
-
- virtual void GetPerfectWindowSize(Rect * perfectSize);
- virtual void GetWindowSizeLimits(Rect * limits);
- virtual void AdjustForNewWindowSize(Rect * oldRect,Rect * newRect);
-
-
- // Window property accessor methods…
- // …watch for new ones when we add scripting support
-
- virtual Boolean IsVisible(void);
-
- virtual Boolean CanClose(void);
- virtual Boolean Close(void);
- virtual Boolean DeleteAfterClose(void);
-
- // Methods for handling menus & menu commands
-
- virtual void AdjustMenusBeforeMenuSelection(void);
- virtual void DoMenuSelection(short menu, short item);
- virtual void DoMenuCommand(unsigned long menuCommand);
-
- // Methods for use with the Drag Manager
-
- virtual OSErr HandleDrag(DragTrackingMessage dragMessage,DragReference theDrag);
-
- virtual OSErr DragEnterWindow(DragReference theDrag);
- virtual OSErr DragInWindow(DragReference theDrag);
- virtual OSErr DragLeaveWindow(DragReference theDrag);
-
- virtual OSErr HandleDrop(DragReference theDragRef);
-
-
- protected:
- WindowPtr fWindow;
- WindowType fWindowType;
-
- Boolean fIsVisible;
- };
-
-
- // Utility Functions:
-
- // Don’t you just wish you didn’t have to do this?
- pascal WindowPtr GetNewColorOrBlackAndWhiteWindow(short windowID, void *wStorage, WindowPtr behind);
- pascal WindowPtr NewColorOrBlackAndWhiteWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, long refCon);
-
- void DrawJustTheGrowIcon(WindowPtr theWindow);
-
- TWindow * GetWindowObject(WindowPtr aWindow);
-
- WindowPtr FrontModalWindow(void);
- WindowPtr LastModalWindow(void);
- WindowPtr FrontFloatingWindow(void);
- WindowPtr LastFloatingWindow(void);
- WindowPtr FrontNonFloatingWindow(void);
-
- void HiliteAndActivateWindow(WindowPtr aWindow,Boolean active);
- void SuspendResumeWindows(Boolean resuming);
- void HiliteWindowsForModalDialog(Boolean hiliting);
-
- pascal OSErr CallWindowDragTrackingHandler(DragTrackingMessage message,WindowPtr theWindow,void *handlerRefCon,DragReference theDragRef);
- pascal OSErr CallWindowDragReceiveHandler(WindowPtr theWindow, void *handlerRefCon,DragReference theDragRef);
-
- #endif
-